<!DOCTYPE html>
<html>

{include file='public/header'}

<body>
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="javascript:void(0)">首页</a>
            <a href="javascript:void(0)">投放管理</a>
            <a><cite>按短剧统计(95折)</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" id="reload" title="刷新">
            <i class="layui-icon" style="line-height:30px"><i class="iconfont">&#xe6aa;</i></i>
        </a>
    </div>
    <div class="x-body">

        <form class="layui-form layui-row" style="margin-top:15px;margin-bottom: 10px;">
            <div class="layui-inline">
                <label class="layui-form-label w-auto">选择短剧：</label>
                <div id="video"></div>
            </div>
            <!-- <div class="layui-inline">
                <label class="layui-form-label w-auto">原剧ID：</label>
                <div class="layui-input-inline">
                    <input type="text" name="original_id" placeholder="请输入原剧ID" autocomplete="off" class="layui-input">
                </div>
            </div> -->

            <div class="layui-inline" style="margin-left:10px">
                <button class="layui-btn" lay-submit lay-filter="searchList">搜索</button>
                <button type="reset" id="resetList" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </form>
        <table id="launchDataList" lay-filter="launchDataList"></table>
    </div>
    <script type="text/html" id="tbBar">
        <a class="layui-btn layui-btn-xs" lay-event="look">查看</a>
    </script>
    <script>
        let totalObj = {}
        let params = {
            elem: '#launchDataList'
            , toolbar: '#toolbarDem'
            , url: '/cps/launch/byShortPlay' //数据接口
            , id: 'launchDataList'
            , limit:15
            , page:true
            , totalRow: true
            , cols: [[ //表头
                { field: 'id', title: '短剧ID', align: 'center', width:86 ,totalRowText: '总合计：'}
                , { field: 'name', title: '短剧名称', align: 'center', width:136}
                , { field: 'cost', title: '花费<i class="layui-icon iconfont icon-lytishi1" id="cost"></i>', align: 'center', sort:true, width:136}
                , { field: 'actual_cost', title: '实际花费<i class="layui-icon iconfont icon-lytishi1" id="actual_cost"></i>', align: 'center', sort:true, width:136}
                , { field: 'register_user_num', title: '注册用户数', align: 'center', width:120}
                , { field: 'activation_user_num', title: '激活用户数<i class="layui-icon iconfont icon-lytishi1" id="activation_user_num"></i>', align: 'center', width:120}
                , { field: 'current_recharge', title: '充值<i class="layui-icon iconfont icon-lytishi1" id="current_recharge"></i>', align: 'center', sort:true, width:136}
                , { field: 'current_recharge_discount', title: '营收<i class="layui-icon iconfont icon-lytishi1" id="current_recharge_discount"></i>', align: 'center', sort:true, width: 125 }
                , { field: 'current_recharge_profit', title: '利润<i class="layui-icon iconfont icon-lytishi1" id="current_recharge_profit"></i>', align: 'center', sort:true, width: 125 }
                , { field: 'current_recovery', title: '回收<i class="layui-icon iconfont icon-lytishi1" id="current_recovery"></i>', align: 'center', width:100}
                , { field: 'current_recovery_discount_95', title: '回收95折<i class="layui-icon iconfont icon-lytishi1" id="current_recovery_discount_95"></i>', align: 'center', width:135 }
                , { field: 'total_recharge', title: '累计充值', align: 'center', sort:true, width:136}
                , { field: 'total_recharge_discount_95', title: '累计充值95折', align: 'center', sort:true, width:135 }
                , { field: 'total_recovery', title: '累计回收', align: 'center', width:100}
                , { field: 'total_recovery_discount_95', title: '累计回收95折', align: 'center', width:135 }
                , { field: 'recharge_number', title: '订单数', align: 'center', sort:true, width:120 }
                , { field: 'conversion_number', title: '充值人数', align: 'center', sort:true, width:120 }
                , { field: 'conversion_cost', title: '转化成本', align: 'center', sort:true, width:106 }
                , { field: 'revenue', title: '营收情况', align: 'center', sort:true, width:136}
                , { field: 'per_capita_contribution', title: '人均贡献', align: 'center', sort:true, width:102}
                // , { toolbar: '#tbBar', title: '操作', align: 'center', width: 65}
            ]],
            customTotal:function(where){
                getTotal('/cps/launch/byShortPlayCount',totalObj,where).then(val=>{
                    totalObj = val
                })
            },
            done: function (res, curr, count) {
                setPrice(totalObj)
                tips('#cost', '#cost', '扣除返点前的花费')
                tips('#actual_cost', '#actual_cost', '扣除返点后的花费')
                tips('#activation_user_num', '#activation_user_num', '今日从推广链接进入的用户数')
                tips('#current_recharge', '#current_recharge', '该剧每日当天充值总和')
                tips('#current_recharge_discount', '#current_recharge_discount', '充值*0.9')
                tips('#current_recharge_profit', '#current_recharge_profit', '营收-实际花费')
                tips('#current_recovery', '#current_recovery', '该剧每日当天回收总和')
                tips('#current_recovery_discount_95', '#current_recovery_discount_95', '该剧每日当天回收总和的9折')
            }
        }
        tableList(params)
        layui.use('table', function () {
            var table = layui.table;
            table.on('tool(launchDataList)', function (obj) {
                var event = obj.event;
                if (event === 'look') {
                    x_admin_show('查看', `./videoInfo.html?video_id=${obj.data.id}`, 1400, 730,null);
                }
            });
        });

        let selectParams2 = {
            url: '/cps/video/select',
            elem: '#video',
            selected: [],
            tips: '选择短剧',
            name: 'video_id',
            field_id: 'id',
            field_Name: 'name',
        }
        selectN(selectParams2)
        
        function setPrice(totalObj){
            Object.keys(totalObj).forEach(item=>{
                $(`.layui-table-total td[data-field=${item}] .layui-table-cell`).text(totalObj[item]);
            })
        }
    </script>
</body>

</html>